<template>
  <el-dialog
    :title="title"
    :close-on-click-modal="false"
     v-dialogDrag
    :visible.sync="visible"
    width="1200%">
    <el-form :model="inputForm" ref="inputForm" :class="method==='view'?'readonly':''"  :disabled="method==='view'" @keyup.enter.native="doSubmit()"
             label-width="100%">
      <el-row  :gutter="15">
        <el-col  >
            <div style="text-align: left;">1.应调取“从事校车业务”或“旅客运输”的相关资质证明文件，并对车辆进行安全性能检测。</div>
          <el-input type="textarea" v-model="inputForm.oneId" placeholder="请填写 1.应调取“从事校车业务”或“旅客运输”的相关资质证明文件，并对车辆进行安全性能检测。"     ></el-input>
        </el-col>
        <el-col  >
           <div style="text-align: left;">2.调取车辆信息查询单，查明涉案车辆核定的载客数量，并对案发时该车辆承载人数进行核实。同时调取乘坐涉案车辆的人员的证言，证实案发时车辆上承载的人数及行驶路线。</div>
           
          <el-input type="textarea" v-model="inputForm.twoId" placeholder="请填写 2.调取车辆信息查询单，查明涉案车辆核定的载客数量，并对案发时该车辆承载人数进行核实。同时调取乘坐涉案车辆的人员的证言，证实案发时车辆上承载的人数及行驶路线。"     ></el-input>
        </el-col>
        <el-col  >
           <div style="text-align: left;">3.调取行驶路段的监控录像及车速检测情况，并及时调取目击者的证言。</div>
           
          <el-input type="textarea" v-model="inputForm.threeId" placeholder="请填写 3.调取行驶路段的监控录像及车速检测情况，并及时调取目击者的证言。"     ></el-input>
        </el-col>
        </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button v-if="method === 'add'" type="primary" @click="continueDoSubmit()">继续添加</el-button>
      <el-button @click="visible = false">关闭</el-button>
      <el-button v-if="method !== 'view'" type="primary" @click="doSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        title: '',
        method: '',
        visible: false,
        oldInputForm: '',
        inputForm: {
          id: '',
          testDataMain: {
            id: ''
          },
          oneId: '',
          twoId: '',
          threeId: '',
          remarks: ''
        }
      }
    },
    components: {
    },
    methods: {
      init (method, obj) {
        this.method = method
        if (method === 'add') {
          this.title = `新建（三）“从事校车业务”或“旅客运输”类危险驾驶的证据收集`
        } else if (method === 'edit') {
          this.title = '修改（三）“从事校车业务”或“旅客运输”类危险驾驶的证据收集'
        } else if (method === 'view') {
          this.title = '查看（三）“从事校车业务”或“旅客运输”类危险驾驶的证据收集'
        }
        this.visible = true
        this.$nextTick(() => {
          this.$refs.inputForm.resetFields()
          this.inputForm.id = ''
          this.oldInputForm = ''
          if (method === 'edit' || method === 'view') { // 修改或者查看
            this.oldInputForm = obj
            this.inputForm = JSON.parse(JSON.stringify(obj))
          }
        })
      },
   // 表单提交
      doSubmit () {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.$emit('addRow', this.oldInputForm, JSON.parse(JSON.stringify(this.inputForm)))
            this.visible = false
          }
        })
      },
      continueDoSubmit () {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.$emit('addRow', this.oldInputForm, JSON.parse(JSON.stringify(this.inputForm)))
            this.$refs['inputForm'].resetFields()
          }
        })
      }
    }
  }
</script>
